//
//  Cache.m
//  GC_OC
//
//  Created by Tianbao Wang on 2022/5/27.
//

#import "Cache.h"

@implementation Cache

+ (instancetype)shared {
    static Cache *sharedAccountManagerInstance = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        sharedAccountManagerInstance = [[self alloc] init];
    });
    return sharedAccountManagerInstance;
}

-(NSString *)user_id{
    UserModel *userModel = [Cache shared].userInfo;
    NSDictionary *diccc = [NSDictionary dictionary];
    if (userModel) {
        NSDictionary *dic = [userModel toDictionary];
        diccc = dic;
        return diccc[@"userinfo"][@"user_id"];
    } else {
        NSDictionary *info = [[NSUserDefaults standardUserDefaults] valueForKey:@"bnyt_userInfo"];
        if (info.count != 0) {
            //先加载本地
            diccc = info;
            return diccc[@"userinfo"][@"user_id"];
        }
    }
    return @"";
}

-(void)removeUser_id{
    UserModel *userModel = nil;
    self.userInfo = userModel;
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"bnyt_userInfo"];
    
}

@end
